#! /usr/bin/env python 
# -*- coding: utf-8 -*-


import task_server,vavava.util,os
import win32event
import win32service
import win32serviceutil

class TaskServerWin32 (win32serviceutil.ServiceFramework):
    _svc_name_ = "TaskServerWin32"
    _svc_display_name_ = "TaskServer"
    def __init__(self, args):
        win32serviceutil.ServiceFramework.__init__(self, args)
        self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
        self.server = task_server.TaskServer()
        self.__args = args
    def SvcStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        self.server.stop()
    def SvcDoRun(self):
        self.server.start()
        self.server.serve()
        self.ReportServiceStatus(win32service.SERVICE_STOPPED)

if __name__=='__main__':
    win32serviceutil.HandleCommandLine(TaskServerWin32)
 